<?php
/**
* 系统运行前处理文件
*
* 本程序主要作用在系统进入Controller前所做的工作
* 
* @category   Common

* @copyright  Copyright (c) ink工作室 (http://www.inkphp.com)
* @author     张旭刚
* @version    v1.0 beta
*/
include(__LIB__.'/adodb/adodb.inc.php');
include(__BASE__.'/Controller.class.php');
include(__BASE__.'/Model.class.php');
$p = P();
$g = G();
$r = R();
if(__USE_ROUTER__){//如果使用Rewrite规则将执行这段代码
    $url = $_SERVER['REQUEST_URI'];
    include(__BASE__.'/Router.class.php');
    $router = new Router($url);
    $data = $router->getRouter();
    foreach((array)$data as $k => $v){
        $g[$k] = $v;
    }
    $app = $g['app'];
    $m = $g['m'];
    $a = $g['a'];
}else{//如果您不使用rewrite规则则执行这个代码
    $app = $g['app'];
    $app = !empty($app)? $app:__DEFAULT_APP__;
    $m = $g['m'];
    $m = !empty($m)? $m:'Index';
    $a = $g['a'];
    $a = !empty($a)? $a:'index';
}
define('APP_NAME', $app);
define('MODEL_NAME', $m);
define('ACTION_NAME', $a);
checkDir();
unset($g['app']);
unset($g['m']);
unset($g['a']);
$data = array('g' => $g, 'r' => $r, 'p' => $p);
unset($_POST);
unset($_GET);
unset($_REQUEST);